<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let print1 = function (obj) {
      console.log(obj)
    }
    let print2 = obj => console.log(obj)
    print2('Java')

    let sum1 = function (a, b) {
      return a + b;
    }
    let sum2 = (a, b) => {
      return a + b
    }
    let sum3 = (a, b) => a + b
    console.log(sum3(3, 5))

    //2.3 对象的函数属性简写
    let person = {
      name: "jack",
      // 以前：
      eat1: function (food) {
        console.log(this.name + "在吃" + food)
      },
      // 箭头函数版：这里拿不到this,this是person外面的域，使用"对象.属性"
      eat2: food => console.log(person.name + "在吃" + food),
      //简写版
      eat3(food) {
        console.log(this.name + "在吃" + food)
      }
    }
    person.eat2('苹果')
    person.eat3('橘子')
  </script>
</body>

</html>